package com.gitee.zycra.file.config;

import java.util.Objects;

/**
 * The config for connect the SFTP server.
 *
 * @author zycra
 * @since 1.0.0
 */
public class ConnectionConfig {

    /**
     * Host of SFTP server.
     *
     * @since 1.0.0
     */
    private final String host;

    /**
     * Username of SFTP server.
     *
     * @since 1.0.0
     */
    private final String username;

    /**
     * Password of SFTP server.
     * <p>Recommend SFTP server config to use connection key instead of password.
     *
     * @since 1.0.0
     */
    private final String password;

    /**
     * Port of SFTP server.
     *
     * @since 1.0.0
     */
    private final Integer port;

    /**
     * Connection key of SFTP server.
     *
     * @since 1.0.0
     */
    private final String connectionKey;

    /**
     * The password of connection key.
     *
     * @since 1.0.0
     */
    private final String passphrase;

    public ConnectionConfig(String host, String username, String password, Integer port, String connectionKey, String passphrase) {
        this.host = host;
        this.username = username;
        this.password = password;
        this.port = port;
        this.connectionKey = connectionKey;
        this.passphrase = passphrase;
    }

    public String getHost() {
        return host;
    }

    public String getUsername() {
        return username;
    }

    public String getPassword() {
        return password;
    }

    public Integer getPort() {
        return port;
    }

    public String getConnectionKey() {
        return connectionKey;
    }

    public String getPassphrase() {
        return passphrase;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        ConnectionConfig that = (ConnectionConfig) o;
        return Objects.equals(host, that.host) && Objects.equals(username, that.username) && Objects.equals(password, that.password)
                && Objects.equals(port, that.port) && Objects.equals(connectionKey, that.connectionKey)
                && Objects.equals(passphrase, that.passphrase);
    }

    @Override
    public int hashCode() {
        return Objects.hash(host, username, password, port, connectionKey, passphrase);
    }
}
